<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>
    <script>
      console.log('广告显示');
      var timer = setTimeout(fn, 3000);
      function fn() {
        console.log('广告关闭了');
      }
    </script>
  </body>
</html>